import {
  HTTP
}
from '../utils/http.js';

import {
  config
}
from '../config/config.js';

class CartModel extends HTTP {
  getCartList() {
    return this.request({
      url: config.CartList
    })
  }

  getCartAdd(p_goodsId, p_number, p_productId) {
    return this.request({
      url: config.CartAdd,
      data: {
        goodsId: p_goodsId,
        number: p_number,
        productId: p_productId
      },
      method: 'POST'
    })
  }
  
  getCartUpdate(p_productId, p_goodsId, p_number, p_id) {
    return this.request({
      url: config.CartUpdate,
      data: {
        productId: p_productId,
        goodsId: p_goodsId,
        number: p_number,
        id: p_id
      },
      method: 'POST'
    })
  }
  
  getCartDelete(p_productIds) {
    return this.request({
      url: config.CartDelete,
      data: {
        productIds: p_productIds
      },
      method: 'POST'
    })
  }
  
  getCartChecked(p_productIds, p_isChecked) {
    return this.request({
      url: config.CartChecked,
      data: {
        productIds: p_productIds,
        isChecked: p_isChecked
      },
      method: 'POST'
    })
  }
  
  getCartGoodsCount() {
    return this.request({
      url: config.CartGoodsCount
    })
  }
  
  getCartCheckout(p_addressId, p_couponId) {
    return this.request({
      url: config.CartCheckout,
      data: {
        addressId: p_addressId,
        couponId: p_couponId
      }
    })
  }
}

export {
  CartModel
}